def login(user, pwd):
    if username == user and passwd == pwd:
        print("登陆成功!")
        input("下一步请按回车....")
        return True
    else:
        print("登陆失败!")
        input("下一步请按回车....")
        return False


def menu1():
    print("**********")
    print("1, 用户登陆")
    print("2, 退出")
    print("**********")


def menu2():
    print("**********")
    print("1, 存款")
    print("2, 取款")
    print("3, 查询账户")
    print("4, 退出")
    print("**********")


# 存款
def dep(dep):
    global User_money, Atm_money
    Atm_money += dep
    User_money += dep


def wit(wit):
    global User_money, Atm_money
    if wit > User_money:
        print("用户账号没有更多金额")
    elif wit > Atm_money:
        print("ATM机没有更多金额")
    else:
        Atm_money -= wit
        User_money -= wit


Atm_money = 50000
User_money = 5000
username = "root"
passwd = "123456"

while True:
    menu1()
    choice1 = input()
    if choice1 == '1':
        username = input("请输入用户名: ")
        passwd = input("请输入用户密码: ")
        if login(username, passwd):
            while True:
                menu2()
                choice2 = input()
                if choice2 == '1':
                    deposit = int(input("请输入存款金额: "))
                    dep(deposit)
                if choice2 == '2':
                    withdrawal = int(input("请输入取款金额: "))
                    wit(withdrawal)
                if choice2 == '3':
                    print("用户账户金额: ", User_money)
                if choice2 == '4':
                    break
                input("下一步请按回车....")
    if choice1 == '2':
        break
